package com.zsy.controller;

import com.zsy.pojo.Emp;
import com.zsy.pojo.LoginInfo;
import com.zsy.pojo.Result;
import com.zsy.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-11 15:26
 **/
@RestController
public class LoginController {
    @Autowired
    private EmpService empService;

    /**
     * 登录功能
     * @param emp
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody Emp emp){
       LoginInfo loginInfo = empService.login(emp);
       if (loginInfo!=null){
           return Result.success(loginInfo);
       }
       return Result.error("登录失败，用户名或密码错误");
    }
}
